import { createStore } from 'vuex'
import StoreSession from './store-session';
const plugin = new StoreSession().create();

export default createStore({
  state: {
    layout: {
      mode : "sidemenu",
      styleColor:"dark",
      themeIndex:0,
      menuCollapsed:false
    }
  },
  mutations: {
    layout_mode: (state,mode:string) => {
      state.layout.mode = mode;
    },
    style_color: (state,color:string) =>{
      state.layout.styleColor = color;
    },
    theme_index: (state,index:number) =>{
      state.layout.themeIndex = index;
    },
    menu_collapsed: (state,states:boolean) =>{
      state.layout.menuCollapsed = states;
    }
  },
  actions: {
    layoutMode({ commit }, mode: string) {
      commit('layout_mode', mode);
    },
    styleColor({ commit }, color: string) {
      commit('style_color', color);
    },
    themeIndex({ commit }, index: number) {
      commit('theme_index', index);
    },
    menuCollapsed({ commit }, states:boolean) {
      commit('menu_collapsed', states);
    }
  },
  modules: {
  },
  getters: {
    layoutMode(state): string {
      return  state.layout.mode;
    },
    styleColor(state): string {
      return  state.layout.styleColor;
    },
    themeIndex(state): number {
      return  state.layout.themeIndex;
    },
    menuCollapsed(state): boolean {
      return  state.layout.menuCollapsed;
    }
  },
  plugins: [plugin]
})
